package com.jack.blog.utils;

import java.io.File;

public final class FileUtil {

    /**
     * if the file not exists and create it
     * @throws Exception
     */
    public static void checkFile(File file)throws Exception{
        if (!file.exists())
            file.createNewFile();
    }

    /**
     * if the directory not exists and create it
     * @throws Exception
     */
    public static void checkDirectory(File directory)throws Exception{
        if (!directory.exists())
            directory.mkdirs();
    }

    /**
     * if the file exists and delete it
     * @param file
     */
    public static void deleteFile(File file){
        if (file.exists())
            file.delete();
    }
}
